package com.liuyi.netty.im.lychat.modular.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.liuyi.netty.im.lychat.modular.enums.MessageType;
import com.liuyi.netty.im.lychat.modular.enums.SessionType;
import com.liuyi.rapid.develop.mybatis.plus.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.ZoneOffset;

/**
 * <p>
 * 消息记录表
 * </p>
 *
 * @author mybatis-plus
 * @since 2021-12-29
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tb_message_records")
@ApiModel(value = "MessageRecords对象", description = "消息记录表")
public class MessageRecords extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "逻辑删除，1未删除，时间戳删除")
    private Long del;

    @ApiModelProperty(value = "消息发送方")
    private String fromId;

    @ApiModelProperty(value = "消息接收方")
    private String toId;

    @ApiModelProperty(value = "会话类型")
    private SessionType sessionType;

    @ApiModelProperty(value = "消息类型")
    private MessageType contentType;

    @ApiModelProperty(value = "消息内容")
    private byte[] content;

    @ApiModelProperty(value = "消息是否吊起发送")
    private Boolean sendIs = false;

    @JsonIgnore
    public long getCreateTimeUnix() {
        return super.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli();
    }

    public static final String ID = "id";

    public static final String DEL = "del";

    public static final String FROM_ID = "from_id";

    public static final String TO_ID = "to_id";

    public static final String SESSION_TYPE = "session_type";

    public static final String CONTENT_TYPE = "content_type";

    public static final String CONTENT = "content";

    public static final String SEND_IS = "send_is";


}
